package yz.cp.back.config.dozer;

import org.dozer.DozerConverter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LocalDateTimeToStringDozerConverter extends DozerConverter<LocalDateTime, String> {
    public LocalDateTimeToStringDozerConverter() {
        super(LocalDateTime.class, String.class);
    }

    public LocalDateTime convertFrom(String source, LocalDateTime destination) {
        return LocalDateTime.parse(source, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public String convertTo(LocalDateTime source, String destination) {
        return DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(source);
    }
}